gh-142518: Annotate PyDict_* C APIs for thread safety#145875
Open
lysnikolaou wants to merge 2 commits intopython:mainfrom
Open
gh-142518: Annotate PyDict_* C APIs for thread safety#145875lysnikolaou wants to merge 2 commits intopython:mainfrom
lysnikolaou wants to merge 2 commits intopython:mainfrom
Conversation
49 tasks
encukou
reviewed
Mar 25, 2026
Comment on lines
+110
to
+115
| In the :term:`free-threaded build`, key hashing via | ||
| :meth:`~object.__hash__` and key comparison via :meth:`~object.__eq__` | ||
| can execute arbitrary Python code, during which the :term:`per-object | ||
| lock` may be temporarily released. For built-in key types | ||
| (:class:`str`, :class:`int`, :class:`float`), the lock is not released | ||
| during comparison. |
Member
There was a problem hiding this comment.
What does this mean for users?
Do they need external synchronization if the dict may contain arbitrary keys?
Contributor
There was a problem hiding this comment.
No, this just means that with arbitrary user defined objects, the operations cannot be considered atomic.
Member
There was a problem hiding this comment.
That sounds like it is atomic with built-in keys but shared with others?
It would be nice to use the same terminology as in the annotations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 Documentation preview 📚: https://cpython-previews--145875.org.readthedocs.build/